﻿// Write a program that finds the greatest of given 5 variables.

using System;

class FindGreatestOf5Vars
{
    static void Main()
    {
        Console.Write("Enter first number : ");
        string numbStr1 = Console.ReadLine();
        double numb1;
        while (!double.TryParse(numbStr1, out numb1))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr1 = Console.ReadLine();
        }

        Console.Write("Enter second number : ");
        string numbStr2 = Console.ReadLine();
        double numb2;
        while (!double.TryParse(numbStr2, out numb2))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr2 = Console.ReadLine();
        }

        Console.Write("Enter third number : ");
        string numbStr3 = Console.ReadLine();
        double numb3;
        while (!double.TryParse(numbStr3, out numb3))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr3 = Console.ReadLine();
        }

        Console.Write("Enter fourth number : ");
        string numbStr4 = Console.ReadLine();
        double numb4;
        while (!double.TryParse(numbStr4, out numb4))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr4 = Console.ReadLine();
        }

        Console.Write("Enter fifth number : ");
        string numbStr5 = Console.ReadLine();
        double numb5;
        while (!double.TryParse(numbStr5, out numb5))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr5 = Console.ReadLine();
        }

        double maxNumber = numb1;
        string numberOfVariable = "first";

        if (maxNumber < numb2)
        {
            maxNumber = numb2;
            numberOfVariable = "second";
        }

        if (maxNumber < numb3)
        {
            maxNumber = numb3;
            numberOfVariable = "third";
        }

        if (maxNumber < numb4)
        {
            maxNumber = numb4;
            numberOfVariable = "fourth";
        }

        if (maxNumber < numb5)
        {
             maxNumber = numb5;
             numberOfVariable = "fifth";
        }

        Console.WriteLine("The greatest variable is the {0} one. Its value is {1}.", numberOfVariable, maxNumber);
        
    }
}
